package br.edu.ufc.deti.broker.persistencia;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class PrsCotas {
	private static PrsCotas instance;
	
	public static synchronized PrsCotas getInstance(){
		if( instance == null )
			instance = new PrsCotas();
		return instance;
	}

	public int getCotaUsuario(Statement stmt, int usuario) {
		int cota = 0;
		ResultSet rs;
		try {
			String query = "SELECT cota FROM usuario where id_usuario = '"+usuario+"'"; 
			rs = stmt.executeQuery( query );
			while (rs.next()) {
				cota = rs.getInt("cota");
			}
			rs.close();
		} catch (IllegalStateException e1) {
			e1.printStackTrace();
		} catch (SQLException e1) {
			e1.printStackTrace();
		}
		return cota;
	}
}
